package com.cwvs.cat.adapter;

import java.util.List;

import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.cwvs.cat.FoundActiveDetailActivity;
import com.cwvs.cat.R;
import com.cwvs.cat.bean.ActiveContent;
import com.cwvs.cat.myview.CustomTextView;

public class MyActiveApplyAdapter extends BaseAdapter {

	private Context mContent;
	private LayoutInflater mInflater = null;
	private ViewHolder holder = null;
	private List<ActiveContent> mList;

	public MyActiveApplyAdapter(Context context, List<ActiveContent> list) {
		this.mContent = context;
		this.mInflater = LayoutInflater.from(context);
		mList = list;

	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return mList.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return mList.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub

		if (convertView == null) {
			convertView = mInflater.inflate(R.layout.item_list_my_active_apply,
					null);
			holder = new ViewHolder();
			holder.title1 = (CustomTextView) convertView.findViewById(R.id.title_1);
			holder.act_release = (CustomTextView) convertView.findViewById(R.id.act_release);
			holder.act_my = (CustomTextView) convertView.findViewById(R.id.act_my);
			holder.txt_active_manager_apply = (CustomTextView) convertView
					.findViewById(R.id.txt_active_manager_apply);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		
		holder.txt_active_manager_apply.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Intent intent = new Intent();
				intent.setClass(mContent, FoundActiveDetailActivity.class);
				mContent.startActivity(intent);
			}
		});

		
		holder.title1.setText(mList.get(position).begin_time);
		holder.act_release.setText(mList.get(position).ownername);
		holder.act_my.setText(mList.get(position).categoryname);
		
		return convertView;
	}

	static class ViewHolder {
		public CustomTextView title1, txt_active_manager_apply,act_release,act_my;

	}

}
